<?php 
include 'config/security.php';
include "../class/PSN.DL.DALC/MarcaDALC.php";
require_once  "../class/PSN.FL/Paginator.php";
?>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Perfect Sport Nutrition</title>
        <link href="css/default-panelcontrol.css" rel="stylesheet" />
    </head>
    <body>
        <div class="header">
            <?php include 'config/header.php'; ?>
        </div>
        <div class="main">
            <div class="mainSubMenu">                <div class="submenuBoton">
                    <a href="pc-marcas.php"><div class="boton">Listado de Marcas</div></a>
                    <a href="pc-marcas-registrar.php"><div class="boton">Registar una Marca</div></a>
                    <div style="clear:both;"></div>
                </div>
            </div>
            <br />
            <div class="mainTitulo">
                <div class="titulo">
                    Listado de Marcas
                </div>
            </div>
            <br />
            <div class="mainContenedor">
                <?php
                    $listMarcaBE=array();
                    $objMarcaDALC= new MarcaDALC();
                    
                    $listMarcaBE=$objMarcaDALC->MarcaListar();
                    $countTotal=count($listMarcaBE);
                    
                    if($countTotal>15)
                    {
                        $objPaginator=new Paginator();
                        $objPaginator->items_total = $countTotal;  
                        $objPaginator->items_per_page=15;
                        $objPaginator->current_page=1;
                        $objPaginator->paginate();  


                        $listMarcaBE=$objMarcaDALC->MarcaListarPorPagina($objPaginator->limit);
                        $count=count($listMarcaBE);
                    }
                    else
                    {
                        $count=$countTotal;
                    }
                ?>
                <table class="grid">
                    <thead>
                        <tr>
                            <th scope="col">Imagen</th>
                            <th scope="col">Nombre Marca</th>
                            <th scope="col">Editar</th>
                            <th scope="col">Eliminar</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
                            for($i=0;$i<$count;$i++)
                            {
                                $objMarcaBE = new MarcaBE();
                                $objMarcaBE=$listMarcaBE[$i];
                        ?>
                        <tr>
                             <td><img class="gridIcon" src=<?php echo '"'.$objMarcaBE->getImagenURL().'"';?> /></td>
                             <td><?php echo $objMarcaBE->getNombreMarca()?></td>
                             <td><center><a href=<?php echo '"pc-marcas-actualizar.php?MarcaID='.$objMarcaBE->getMarcaID().'"';?>><img class="gridAction" src="images/imgEditar.png" /></a></center></td>
                             <td><center><a href=<?php echo '"process_MarcaEliminar.php?MarcaID='.$objMarcaBE->getMarcaID().'"';?> onclick="return confirm('¿Estas seguro de eliminar el registro?');"><img class="gridAction" src="images/imgEliminar.png" /></a></center></td>
                        </tr>
                        <?php
                            }
                        ?>
                    </tbody>
                </table>
                 <div class="gridPaginator">
                    <?php
                        if($countTotal>15)
                         echo $objPaginator->display_pages(); 
                    ?>
                </div>
                <br /><br /><br />
            </div>
        </div>
        <div class="footer">
            <?php include 'config/footer.php'; ?>
        </div>
    </body>
</html>
